#include <gtest/gtest.h>
#include <algorithm>
#include "internal_sort.hpp"

class SortTest : public testing::Test {
protected:
    void SetUp() override {
        // 测试数据初始化
        test_array = {4, 6, 7, 2, 10, 54, 31, 92, 113, 3, 1, 0, 8};
        sorted_array = test_array;
        std::sort(sorted_array.begin(), sorted_array.end());
    }

    std::vector<int> test_array;
    std::vector<int> sorted_array;
};

TEST_F(SortTest, InsertSort) {
    std::vector<int> arr = test_array;
    insert_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, MidInsertSort) {
    std::vector<int> arr = test_array;
    mid_insert_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, ShellSort) {
    std::vector<int> arr = test_array;
    shell_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, SelectSort) {
    std::vector<int> arr = test_array;
    select_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, HeapSort) {
    std::vector<int> arr = test_array;
    heap_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, QuickSort) {
    std::vector<int> arr = test_array;
    quick_sort(arr.data(), 0, arr.size() - 1);
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, MergeSort) {
    std::vector<int> arr = test_array;
    merge_sort(arr.data(), 0, arr.size() - 1);
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, CountSort) {
    std::vector<int> arr = test_array;
    count_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

TEST_F(SortTest, RadixSort) {
    std::vector<int> arr = test_array;
    radix_sort(arr.data(), arr.size());
    EXPECT_EQ(arr, sorted_array);
}

int main(int argc, char **argv) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}